

const http = require('http');
const url = require('url');

const { render } = require("./tool/renderSite.js");

// const path = require('path');
// const fs = require('fs');
// const fsp = fs.promises;

const { createServer } = http;

var server = createServer();


server.on("request", function (req, res) {
    if (req.url != "/favicon.ico") {
        console.log("接收前端发送的请求");
        console.log(req.url);

        var urlInfo = url.parse(req.url, true);
        // console.log(urlInfo);

        var { pathname, query } = urlInfo;


        render(pathname, res);





    } else {
        res.end();
    }
})


server.listen(3000, function () {
    console.log("服务器启动成功localhost:3000");
})

